﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Drawing;
using DevExpress.XtraGrid.Views.Grid;

namespace ESOL.Controls
{
    public partial class DevDataGridView : DevExpress.XtraGrid.GridControl
    {
        public DevDataGridView()
        {
            InitializeComponent();
            this.Load += new EventHandler(DevDataGridView_Load);
        }

        private void DevDataGridView_Load(object sender, EventArgs e)
        {
            if (this.MainView != null)
            {
                if (this.MainView.GetType() == typeof(GridView))
                {
                    GridView thisGridView = (GridView)this.MainView;                    
                    thisGridView.OptionsView.ShowGroupPanel = false;
                    thisGridView.OptionsView.EnableAppearanceEvenRow = true;
                    thisGridView.OptionsView.EnableAppearanceOddRow = true;
                    thisGridView.Appearance.OddRow.BackColor = Color.FromArgb(234, 234, 234);
                    thisGridView.Appearance.EvenRow.BackColor = Color.White;
                    thisGridView.IndicatorWidth = 40;
                    thisGridView.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView1_CustomDrawRowIndicator);
                }
            }
        }

        private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator && e.RowHandle >= 0)
            {
                e.Info.DisplayText = (e.RowHandle + 1).ToString();
            }
        }

        public DevDataGridView(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
            this.Load += new EventHandler(DevDataGridView_Load);
        }


    }
}
